<table id="manage_ticket" data-options="fit:true"></table>
<script>
$(function(){
	$.ajax({
	    url: "../json/LocalInfo_getLids",    //请求的url地址
	    dataType: "json",   //返回格式为json
	    async: true, //请求是否异步，默认为异步，这也是ajax重要特性
	    type: "POST", 
	    success: function(data) {
	    	var info="";
	    	for(var i=0;i<data.rows.length;i++){
	    		info+="<option value="+data.rows[i]+">"+data.rows[i]+"</option>";
	    	}
	    	$("#ticket_lid").append(info);
	    }
	});
	
	$('#manage_ticket').datagrid({
		url:'../json/Ticket_getTicketList',
		loadMsg:'数据加载中...',
		fitColumns:true,
		rownumbers:true,
		striped:true,
		sortName:'tid',
		sortOrder:'asc',
		remoteSort:false,
		columns:[[
			{field:'tids',title:'',width:100,align:'center',checkbox:true},
			{field:'tid',title:'门票编号',width:30,align:'center',sortable:true},
			{field:'lid',title:'关联景区',width:30,align:'center'}, 
			{field:'ttype',title:'门票类型',width:100,align:'center'}, 
			{field:'tprice',title:'门票价格',width:100,align:'center'}
		]],
		toolbar: [{
			iconCls: 'icon-add',
			text:'添加',
			handler: function(){
				$("#add_ticket").dialog("open");
			}
		},'-',{
			iconCls: 'icon-remove',
			text:'删除',
			handler: function(){
				alert('help')
			}
		}]
	});
});

function addTicketInfo(){
	var ttype=$("#ticket_ttype").val();
	var tprice=$("#ticket_tprice").val();
	var lid=$("#ticket_lid").val();
	$.ajax({
	    url: "../json/Ticket_addTicketInfo",    //请求的url地址
	    dataType: "json",   //返回格式为json
	    async: true, //请求是否异步，默认为异步，这也是ajax重要特性
	    type: "POST",
	    data:{
	    	"ttype":ttype,
	    	"tprice":tprice,
	    	"lid":lid
	    },
	    success: function(data) {
	    	if(parseInt($.trim(data.obj))>=1){
	    		$.messager.show({
					title:'成功提示',
					msg:'添加信息成功！',
					timeout:3000,
					showType:'slide'
				});
	    		$("#add_ticket").dialog("close");
	    		$("#ticket_ttype").val("");
	    		$("#ticket_tprice").val("");
	    		$("#ticket_lid").val("");
				$('#manage_ticket').datagrid("reload");
	    	}else{
	    		$.messager.alert('错误提示','添加信息失败,请稍后重试!','error');
	    	}
	    }
	});
}

</script>
<div id="add_ticket" class="easyui-dialog" title="添加门票" style="width:400px;height:250px;"
	data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">
	<p style="width:100%;text-align:center;">
		<br /> <br /> 
		<label for="ticket_ttype">门票类型：</label><input type="text" id="ticket_ttype">
		<br /> <br /> 
		<label for="ticket_tprice">门票价格：</label><input type="text" id="ticket_tprice">
		<br /> <br />
		<label>关联景区：</label>
		<select id="ticket_lid">
			<option value="">请选择关联景区</option>
		</select>
		<br/><br/>
		<input style="padding:5px 25px;" type="button" onclick="addTicketInfo()" value="添加">
	</p>
</div>

